
//
//  HWTopicsCommentTableViewCell.m
//  HappyWeekend
//
//  Created by 赵洁 on 16/1/14.
//  Copyright © 2016年 com.mjykj.www. All rights reserved.
//

#import "HWTopicsCommentTableViewCell.h"
#import <UIKit/UIKit.h>
typedef double NSTimeInterval;
@implementation HWTopicsCommentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        
        _userImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 50, 50)];
        _userImage.layer.cornerRadius = 25;
        _userImage.layer.masksToBounds = YES;
        //_userImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_userImage];
        
        _phoneLable = [[UILabel alloc]initWithFrame:CGRectMake(_userImage.right+5, _userImage.top+10, _userImage.width*3, 30)];
        _phoneLable.numberOfLines = 0;
        _phoneLable.font = [UIFont systemFontOfSize:15];
        //_phoneLable.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_phoneLable];
        _commentLable = [[UILabel alloc]initWithFrame:CGRectMake(_phoneLable.frame.origin.x, _phoneLable.bottom+10, kScreenWidth, 50)];
        _commentLable.numberOfLines = 0;
        _commentLable.font = [UIFont systemFontOfSize:14];
        //_commentLable.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_commentLable];
        _timelable = [[UILabel alloc]initWithFrame:CGRectMake(_phoneLable.right+20, _phoneLable.top, _phoneLable.width, 20)];
        _timelable.numberOfLines = 0;
        _timelable.font = [UIFont systemFontOfSize:10];
        _timelable.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_timelable];
        
    }
    return self;
}

- (void)setModel:(HWCommentModel *)model
{
    _model = model;
    [_userImage sd_setImageWithURL:[NSURL URLWithString:model.avatar_url]];
    _commentLable.text = model.content;
    NSString *string = [NSString stringWithFormat:@"%@",model.created_at];
    NSInteger sec = [string integerValue];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:sec];
    NSDate *nowTime = [date dateByAddingTimeInterval:28800];
    NSTimeZone *zone = [NSTimeZone timeZoneForSecondsFromGMT:8];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
    NSString *str = [formatter stringFromDate:nowTime];
    _phoneLable.text = model.nickname;
    _timelable.text = str;
    
    
   

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
